No — that is one of the advantages of using StringBuffer
.
A palindrome is a string that reads the same when it is reversed. Punctuation, spaces, and capitalization are ignored. For example, the following is a palindrome:
A man, a plan, a canal, Panama!
Let us write a program that determines if a
string is a palindrome.
In this program,
the string is hard-coded in the program
as a String
object.
class Tester { public boolean test( String trial ) { . . . . } } public class PalindromeTester { public static void main ( String[] args ) { Tester pTester = new Tester(); String trial = "A man, a plan, a canal, Panama!" ; if ( pTester.test( trial ) ) System.out.println( "Is a Palindrome" ); else System.out.println( "Not a Palindrome" ); } }
Class String
has a method toLowerCase()
and a method toUpperCase()
.
Will these methods be useful?